package io.renren.modules.backstage.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.modules.backstage.dao.FinanceDao;
import io.renren.modules.backstage.entity.FinanceEntity;
import io.renren.modules.backstage.service.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("financeService")
public class FinanceServiceImpl implements FinanceService {
    @Autowired
    FinanceDao financeDao;

    /**
     * 财务报表数据查询
     * @return
     */
    @Override
    public List<FinanceEntity> getFinanceAll(Integer parentId) {
        QueryWrapper<FinanceEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id",parentId);
        List<FinanceEntity> list = financeDao.selectList(queryWrapper);
        return list;
    }

    @Override
    public void imPort() {
        String fileName = "d:/excel202205/FinanceWrite.xlsx";
        EasyExcel.write(fileName, FinanceEntity.class).sheet("模板").doWrite(data());

    }

    private  List<FinanceEntity> data() {
        List<FinanceEntity> entityList = financeDao.selectList(null);
        return entityList;
    }
}
